import { ref } from 'vue'
import type { DrawerIframeCallBack } from './types'

export const drawerIframeVisible = ref(false)
export const drawerIframeSrc = ref('')
export const drawerIframeCallBack = ref<DrawerIframeCallBack>({})

/**
 * 使用drawer iframe打开链接
 * @param src iframe的src
 * @param callback iframe drawer的callback, { open, opened, close, closed }
 */
export const useDrawerIframe = (
  src: string,
  callback: DrawerIframeCallBack = {}
) => {
  drawerIframeSrc.value = src
  drawerIframeCallBack.value = callback
  drawerIframeVisible.value = true
}
